#ifndef OGRERENDERWIDGET_H
#define OGRERENDERWIDGET_H

#include <QWidget>
#include <QString>
#include <string>
class OgreRenderWidget : public QWidget
{
public:
	OgreRenderWidget(QWidget* parent=0, Qt::WindowFlags f=0);
	~OgreRenderWidget();
	void Go();
	void SetBkgColor(const Ogre::ColourValue& color);
	const Ogre::ColourValue& GetBkgColor() const;
	void SetPlaneMeshVisible(bool isVisible);
protected:
	bool setup();
	void setupResources();
	bool configure();
	void createSceneManager();
	void createCamera();	
	void createViewport();
	void createScene();
	void destroyScene();	
	void loadResources();
	virtual void createFrameListener();
	void createParticles();
	void yawCameraAroundWorld( Ogre::Real theta );
protected:// Override
	void timerEvent(QTimerEvent *e);
	void paintEvent(QPaintEvent *e);
	void resizeEvent(QResizeEvent *e);
	void renderOneFrame();
	QPaintEngine* paintEngine() const;
	void mousePressEvent(QMouseEvent *e);
	void mouseMoveEvent(QMouseEvent *e);
	void mouseReleaseEvent(QMouseEvent *e);
	void keyPressEvent(QKeyEvent *e);
	void keyReleaseEvent(QKeyEvent *e);
protected:
	Ogre::Root*			m_pRoot;
	Ogre::Camera*		m_pCamera;
	Ogre::SceneNode*	m_pCameraNode;
	Ogre::SceneManager* m_pSceneMgr;
	Ogre::SceneNode*	m_pRootNode;
	Ogre::RenderWindow* m_pWindow;
	Ogre::Viewport*		m_pViewport;
	// PlaneMesh
	Ogre::SceneNode*	m_pPlaneMeshNode;
	Ogre::String mConfigFileName;
	Ogre::String mPluginsFileName;
	Ogre::String mLogFileName;
	Ogre::String mResCfgFileName;

	bool m_bLeftPressed;
	QPoint	m_leftPressedPoint;
	Ogre::Vector3 m_translateVec;
	Ogre::Real  m_yawSpeed;
	Ogre::Real	m_pitchSpeed;
};

#endif // OGRERENDERWIDGET_H
